<%layout("/common/_layout.html"){ %>
  <%#ajax userTable:{%>
  <div class="am-cf am-padding">
    <div class="am-fl am-cf"><strong class="am-text-primary am-text-lg">报表中心</strong> / <small>V网成员报表</small></div>
  </div>
  <div class="am-g">
    <div class="am-u-sm-12">
      <form class="am-form" id="list-form" action="${base}/vmemberOrder/list" method="post">
        <input type="hidden" id="keywords" name="keywords" value='${keywords!""}' />
        <input type="hidden" id="isExport" name="isExport" value='${isExport!"0"}' />
        <table class="am-table am-table-bordered am-table-radius table-main" style="padding:0;">
          <tbody>
            <tr>
              <th class="am-text-middle">店员所属机构</th>
              <td>
                 <div class="am-u-sm-10">
                        <select data-am-selected="{btnSize:'sm',maxHeight: 400,btnWidth:'100%'}" name="org_id" id="org_id">
                            <%for(orgNode in orgList){%>
                            <option value="${orgNode.value}" <%if(org_id==orgNode.value){%>
                                selected
                                <%}%>>${orgNode.key}</option>
                            <%}%></select>
                    </div>
              </td>
              <th class="am-text-middle">办理时间</th>
              <td>
                   <div class="am-u-sm-10">
                    <div class="am-form am-form-inline">
                          <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" class="am-form-field am-input-sm" id="startTime" value="${startTime!}" placeholder="开始日期" data-am-datepicker readonly>
                          </div>
                      <div class="am-form-group">至</div>
                      <div class="am-form-group am-form-icon">
                            <i class="am-icon-calendar"></i>
                            <input type="text" class="am-form-field am-input-sm" id="endTime" value="${endTime!}" placeholder="结束日期" data-am-datepicker readonly>
                      </div>
                      <span class="am-text-danger">*默认显示最近一个月的数据</span>
                    </div>
                   </div>

                </td>
            </tr>
            <tr>
              <th class="am-text-middle">V网名称</th>
              <td>
                <div class="am-u-sm-10">
                  <input type="text" id="vgroupname" class="am-form-field am-input-sm" value="${vgroupname!}" />
                </div>
              </td>
              <th class="am-text-middle">V网编码</th>
              <td>
              <div class="am-u-sm-10">
                  <input type="text" id="vgroupcode" class="am-form-field am-input-sm" value="${vgroupcode!}" />
                </div>
            </td>
            </tr>

            <tr>
              <th class="am-text-middle">店员姓名</th>
              <td>
                <div class="am-u-sm-10">
                  <input type="text" id="username" class="am-form-field am-input-sm" value="${username!}" />
                </div>
              </td>
              <th class="am-text-middle">店员手机</th>
              <td>
              <div class="am-u-sm-10">
                  <input type="text" id="usermobile" class="am-form-field am-input-sm" value="${usermobile!}" />
                </div>
            </td>
            </tr>
            <tr>
              <th class="am-text-middle">成员手机</th>
              <td>
                <div class="am-u-sm-10">
                  <input type="text" id="member" class="am-form-field am-input-sm" value="${member!}" />
                </div>
              </td>
              <td colspan="4">
                                <div align='right'>
                                  <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn" onClick="submit_btn('search');">搜索</button>
                                  <%if(so.hasPermission("CMCC_VMEMBER_EXPORT")) {%>
                                  <button type="button" class="am-btn am-btn-default am-btn-sm am-text-secondary" id="submit-btn" onClick="submit_btn('export');">导出</button>
                                  <%}%>
                                </div>
                              </td>
            </tr>

          </tbody>
        </table>
      </form>
    </div>
    <div class="am-u-sm-12 am-u-md-12" style="padding:0 1.6rem 1.6rem 1rem;margin:0;">
      <div class="am-btn-toolbar" style="padding-left:.5rem;">
      </div>
    </div>
  </div>
  <div class="am-g">
    <div class="am-u-sm-12">
    <div class="am-scrollable-horizontal">
      <table class="am-table am-table-striped am-table-hover table-main">
        <thead>
          <tr class="am-text-nowrap">
            <th class="table-title">V网名称</th>
            <th class="table-title">V网编码</th>
            <th class="table-title">业务类型</th>
            <th class="table-title">V网成员</th>
            <th class="table-title">成员短号</th>
            <th class="table-title">资费名</th>
            <th class="table-title">费率</th>
            <th class="table-title">店员姓名</th>
            <th class="table-title">店员手机</th>
            <th class="table-title">地市</th>
            <th class="table-title">区县</th>
            <th class="table-title">渠道编码</th>
            <th class="table-title">渠道名称</th>
            <th class="table-title">渠道类型</th>
            <th class="table-title">客户经理</th>
            <th class="table-title">办理时间</th>

          </tr>
        </thead>
        <tbody>
          <%for(list in pager.list!){%>
            <tr>
              <td>${list.v_name}</td>
              <td>${list.v_code}</td>
              <td>${list.opType}</td>
              <td>${list.v_member}</td>
              <td>${list.v_short}</td>
              <td>${list.v_pkg_name}</td>
              <td>${list.v_pkg_rate}</td>
              <td>${list.user_name}</td>
              <td>${list.user_mobile}</td>
              <td>${list.city}</td>
              <td>${list.quxian}</td>
              <td>${list.channel_code}</td>
              <td>${list.channel_name}</td>
              <td>${list.channel_type}</td>
              <td>${list.is_accounts_manager}</td>
              <td>${list.opTime}</td>
            </tr>
           <%}%>
        </tbody>
     </table>
     </div>
      <div class="am-cf">
         <!-- 分页 -->
         <%if (pager.list.~size > 0){%>
             <div class="am-fr">
                 <% include("/admin/common_pager.tpl"){}%>
             </div>
         <%}else{%>
             <div class="am-kai">
               <h3>没有找到任何记录!</h3>
             </div>
         <%}%>
      </div>

    </div>
  </div>
  <script type="text/javascript">
      var keywordsObj = {};

      var submit_btn = function(businessType){
    	  if($("#org_id").val())
            keywordsObj.org_id = $("#org_id").val();
            if($("#username").val())
            keywordsObj.username = $("#username").val();

            if($("#endTime").val()!="" && $("#endTime").val() < $("#startTime").val()){
                	alert("结束时间不能小于开始时间");
                	return false;
            }

            var start = $("#startTime").val();
            var end = $("#endTime").val();
            if(start && end){
              keywordsObj.startTime = start;
              keywordsObj.endTime = end;
              keywordsObj.create_date = start + "|" + end;
            }
            if($("#usermobile").val())
                keywordsObj.usermobile = $("#usermobile").val();

            if($("#member").val())
              keywordsObj.member = $("#member").val();

            if($("#vgroupname").val())
              keywordsObj.vgroupname = $("#vgroupname").val();

            if($("#vgroupcode").val())
              keywordsObj.vgroupcode = $("#vgroupcode").val();


            var keywords = "";
            if(!$.isEmptyObject(keywordsObj)){
              keywords = JSON.stringify(keywordsObj);
            }
            console.log("keywords = "+ keywords);

            $("#keywords").val(keywords);

            if(businessType == "search"){
            		window.location.href = "${base}/vmemberOrder/list?keywords="+keywords;
            	}else if(businessType == "export"){
            		window.location.href = "${base}/vmemberOrder/export?keywords="+keywords;
            }
      }

  </script>
  <%}%>
<%}%>